package com.jy.adscm.zltx.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.zltx.bean.QsAttachment;
import com.jy.adscm.zltx.mapper.mysql.QsAttachmentMapper;
import com.jy.adscm.zltx.service.QsAttachmentService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2018-11-07
 */
@Service
public class QsAttachmentServiceImpl extends ServiceImpl<QsAttachmentMapper, QsAttachment> implements QsAttachmentService {
   @Autowired
    JyUserMapper jyUserMapper;
           @Autowired
           QsAttachmentMapper qsAttachmentMapper;
    @Override
    public List<QsAttachment> selectQsAttachments(Integer fileId) throws AdscmSystemException {
        Wrapper<QsAttachment> Wrapper =new EntityWrapper<>();
        Wrapper.eq("fileId",fileId);
        List<QsAttachment> qsAttachments = qsAttachmentMapper.selectList(Wrapper);
        for (QsAttachment qsAttachment : qsAttachments) {
            if (  qsAttachment.getUploadPerson()!=null&& !"".equals(  qsAttachment.getUploadPerson())){
                JyUser jyUser = jyUserMapper.selectById(qsAttachment.getUploadPerson());
                qsAttachment.setUploadPersonName(jyUser.getName());
            }
        }
        return qsAttachments;
    }
}
